package com.choupin.choupin.utils;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;

import java.rmi.ServerException;

public class SmsPhone {

    public static void main(String[] args) {
        // 替换为你的AccessKey ID和AccessKey Secret
        String accessKeyId = "your_access_key_id";
        String accessKeySecret = "your_access_key_secret";

        // 创建默认的AcsClient实例
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        IAcsClient client = new DefaultAcsClient(profile);

        // 设置请求参数
        SendSmsRequest request = new SendSmsRequest();
        request.setPhoneNumbers("13800138000"); // 接收短信的手机号码
        request.setSignName("your_sign_name"); // 短信签名名称
        request.setTemplateCode("your_template_code"); // 短信模板CODE
        request.setTemplateParam("{\"code\":\"123456\"}"); // 短信模板中的变量值，例如验证码

        try {
            // 发送请求并打印结果
            SendSmsResponse response = client.getAcsResponse(request);
            System.out.println(response.getCode());
            System.out.println(response.getMessage());
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }


}
